class Solution
{
public:
    int reachableNodes(int n, vector<vector<int>> &edges, vector<int> &__restricted)
    {
        vector<vector<int>> adjTable(n, vector<int>());
        for (auto &edge : edges)
        {
            adjTable[edge[0]].push_back(edge[1]);
            adjTable[edge[1]].push_back(edge[0]);
        }
        queue<int> q;
        q.push(0);
        int visitedCount = 1;
        unordered_set<int> restricted(__restricted.begin(), __restricted.end());
        restricted.insert(0);
        while (!q.empty())
        {
            int node = q.front();
            q.pop();
            for (int adjNode : adjTable[node])
            {
                if (!restricted.count(adjNode))
                {
                    ++visitedCount;
                    restricted.insert(adjNode);
                    q.push(adjNode);
                }
            }
        }
        return visitedCount;
    }
};